package com.sparkseries.enums;

/**
 * 默认状态
 */
public enum DefaultStatusEnum {
    /**
     * 禁用
     */
    DISABLED(0, "禁用"),

    /**
     * 启用
     */
    ENABLED(1, "启用");

    private final Integer code;
    private final String desc;

    DefaultStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return this.code;
    }

    public static boolean isValid(int code) {
        return code == DISABLED.code || code == ENABLED.code;
    }

    public static String getDesc(int code) {
        for (DefaultStatusEnum status : values()) {
            if (status.code == code) {
                return status.desc;
            }
        }
        return "未知状态";
    }
}
